check if a source NAT IP address is needed before assigning one#12408
check if a source NAT IP address is needed before assigning one#12408DaanHoogland wants to merge 1 commit intoapache:4.20from
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 4.20 #12408 +/- ##
=========================================
Coverage 16.23% 16.24%
Complexity 13381 13381
=========================================
Files 5657 5657
Lines 498947 499002 +55
Branches 60555 60571 +16
=========================================
+ Hits 81025 81039 +14
- Misses 408889 408924 +35
- Partials 9033 9039 +6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@blueorangutan package |
|
@DaanHoogland a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 16344 |
There was a problem hiding this comment.
Pull request overview
This PR addresses issue #10122 regarding incorrect IP address labeling as "Source NAT" in Routed VPC networks. The main change introduces logic to check if a network is routed before assigning a source NAT IP address, which prevents unnecessary source NAT IP allocation for routed networks where Source NAT service is not applicable.
Changes:
- Adds new
isRouted()method to determine if a network uses routing mode - Updates
assignSourceNatIpAddressToGuestNetwork()to conditionally assign source NAT based on routing mode - Updates
isSourceNatAvailableForNetwork()to treat networks with routing mode as having shared source NAT - Includes extensive code cleanup: removes unused imports and fields, applies diamond operators, and simplifies conditional logic
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
server/src/main/java/com/cloud/network/IpAddressManagerImpl.java
Outdated
Show resolved
Hide resolved
server/src/main/java/com/cloud/network/IpAddressManagerImpl.java
Outdated
Show resolved
Hide resolved
server/src/main/java/com/cloud/network/IpAddressManagerImpl.java
Outdated
Show resolved
Hide resolved
|
@DaanHoogland |
it is not a pure UI issue. The IP address is marked as source NAT in the DB. I am not sure if this addresses all scenarios yet, but it will prevent marking the primary IP for a ROUTED-mode network as source NAT. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 10 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
server/src/main/java/com/cloud/network/IpAddressManagerImpl.java
Outdated
Show resolved
Hide resolved
server/src/main/java/com/cloud/network/IpAddressManagerImpl.java
Outdated
Show resolved
Hide resolved
server/src/main/java/com/cloud/network/IpAddressManagerImpl.java
Outdated
Show resolved
Hide resolved
server/src/main/java/com/cloud/network/IpAddressManagerImpl.java
Outdated
Show resolved
Hide resolved
server/src/main/java/com/cloud/network/IpAddressManagerImpl.java
Outdated
Show resolved
Hide resolved
server/src/main/java/com/cloud/network/IpAddressManagerImpl.java
Outdated
Show resolved
Hide resolved
server/src/main/java/com/cloud/network/IpAddressManagerImpl.java
Outdated
Show resolved
Hide resolved
server/src/main/java/com/cloud/network/IpAddressManagerImpl.java
Outdated
Show resolved
Hide resolved
e8cebc6 to
7274c9e
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
server/src/main/java/com/cloud/network/IpAddressManagerImpl.java
Outdated
Show resolved
Hide resolved
| private boolean isRouted(Network guestNetwork) { | ||
| VpcOffering vpcOffer = null; | ||
| NetworkOffering netOffer = _networkOfferingDao.findById(guestNetwork.getNetworkOfferingId()); | ||
| if (netOffer == null) { | ||
| throw new CloudRuntimeException("network without offering found???"); | ||
| } | ||
| if (netOffer.isForVpc() && guestNetwork.getVpcId() != null) { | ||
| VpcVO vpc = _vpcDao.findById(guestNetwork.getVpcId()); | ||
| if (vpc != null) { | ||
| vpcOffer = vpcOfferingDao.findById(vpc.getVpcOfferingId()); | ||
| } | ||
| } | ||
| return netOffer.getRoutingMode() != null || (vpcOffer != null && vpcOffer.getRoutingMode() != null); | ||
| } |
There was a problem hiding this comment.
The new isRouted method lacks test coverage. Since the repository has comprehensive test coverage for IpAddressManagerImpl (see IpAddressManagerTest.java), consider adding unit tests to verify:
- The method correctly identifies routed networks based on NetworkOffering routing mode
- The method correctly identifies routed VPC networks based on VPC offering routing mode
- Edge cases like null VPC or null VPC offering are handled properly
7274c9e to
519b8cf
Compare
ok @DaanHoogland as I understand, what @msinhore wanted is the change of label of public IP. |
isSourceNat is a flag returned to the UI, if we do not change it in the service we have to honour that flag conditionally. Not a very clean solution either and technical debt at the same time. I would suggest we fix it good or not. |
ok. a simple workaround on UI
|
Description
This PR...
Fixes: #10122
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
How did you try to break this feature and the system with this change?